package start.demo01.datatype.datasource;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;

public class DataSourcePool {

    private Map<String,DataSource> map=new HashMap<>();

    public DataSourcePool() {
        map.put("key1",getDataSource1());
    }
    public DataSource getDataSource(String key){
        return map.get(key);
    }

    public DataSource getDataSource1() {
        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setJdbcUrl("jdbc:mysql://192.168.150.151:3306/info?charactorEncoding=utf-8&useSSL=false");
        hikariConfig.setUsername("root");
        hikariConfig.setPassword("password");
        hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        hikariConfig.setMaxLifetime(1000*60*30);
        HikariDataSource dataSource = new HikariDataSource(hikariConfig);
        return dataSource;
    }


}
